#include "Janus.h"
#include "Pandora.h"
namespace request_manager
{
std::string Janus::label = "auth";

std::string Janus::authorize_m = "/authorize";
std::string Janus::set_device_info_m = "/devices/mydevice";
std::string Janus::link_credential_m = "/users/me/credentials";
std::string Janus::unlink_credential_m = "/users/me/credentials/#/unlink";
std::string Janus::me_m = "/users/me";
std::string Janus::account_info_m = "/users/#";
std::string Janus::get_other_game_account_m = "/users/#/games/#";
std::string Janus::refresh_access_token_m = "/authorize";
std::string Janus::create_transfer_code_m = "/users/me/transfer_code";
std::string Janus::transfer_code_token_m = "/auhtorize";
std::string Janus::encrypt_token_m = "/encrypt_token";
std::string Janus::authenticate_m = "/#/authenticate";
std::string Janus::change_password_m = "/users/me/#/change_password";
std::string Janus::create_alias_m = "/games/mygame/alias";
std::string Janus::lookup_alias_m = "/games/mygame/alias/#";
std::string Janus::generate_captcha_m = "/captchas";

Janus::Janus() : Service()
{
	Pandora pandora;
	Response response = pandora.locate(label);
	service_url = "https://" + response.data;
}


Janus::~Janus()
{

}


Response Janus::authorize(std::string username, std::string password, std::string scope, std::string client_id)
{
	std::string url = service_url.append(authorize_m);
	Request request = Request(url);
	
	std::string data = "username=" + username + "&";
	data += "password=" + password + "&";
	data += "scope=" + scope + "&";
	data += "client_id=" + client_id;
	
	request.data = data;

	Response response = Requester::_doPOST(&request);

	return response;
}

}